package com.zslc.securitymonitoring.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @description:
 * @author: Gaoyc
 * @date: 2024-06-12 20:05
 **/
public class ListUtil {
    public static <T> List<T> paginate(List<T> originalList, int page, int pageSize) {
        if (originalList == null || originalList.isEmpty()) {
            return new ArrayList<>();
        }
        int fromIndex = (page - 1) * pageSize;
        int toIndex = Math.min(fromIndex + pageSize, originalList.size());
        return originalList.subList(fromIndex, toIndex);
    }
}
